# -*- coding:utf-8 -*-
import enum
from datetime import datetime
from typing import Any, Dict, List, Optional, Sequence, Union

from pydantic import BaseModel,Field


class Job(BaseModel):
    id: str
    name: Optional[str] = None
    func: Optional[str] = None
    # if python 3.9.x, can use `tuple` key word to replace `Sequence[Optional[str]]`,
    # else use `Sequence[Optional[str]]` to deal with the issue about tuple length error.
    args: Optional[Sequence[Optional[str]]] = None
    kwargs: Optional[Dict[str, Any]] = None
    executor: Optional[str] = None
    misfire_grace_time: Optional[str] = None
    coalesce: Optional[bool] = None
    max_instances: Optional[int] = None
    next_run_time: Optional[Union[str, datetime]] = None

class TriggerEnum(str, enum.Enum):
    # date = "date"
    interval = "interval"
    # cron = "cron"




class AddJob(BaseModel):
    id: str 
    msg:  Optional[str] = "默认Job"
    verbose: bool = Field(..., description="是否开启任务",title="是否开启任务，True 或者False")
    seconds:int=120 
    trigger_args: Optional[Dict[str, Any]]
    func:  Optional[str] = "Mytest"


class UpdateJob(BaseModel):
    id: str 
    seconds:int=120
    trigger_args: Optional[Dict[str, Any]]




class  RootKey(BaseModel):
    """  基础Rootkey """
    id: str

class TriggerEnum(str, enum.Enum):
    # date = "date"
    interval = "interval"
    # cron = "cron"



class BaseResponse(BaseModel):
    message: str
    status_code: Union[int, str]


class QueryResponse(BaseResponse):
    jobs: List[Job]


class OperateResponse(BaseResponse):
    type: str

